/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package scrabble;

import java.awt.dnd.DnDConstants;
import java.awt.dnd.DragSource;
import javax.swing.ImageIcon;
import javax.swing.JLabel;

/**
 *
 * @author KhoufiAsma
 */
public class Lettre extends JLabel{
    private int valeur;
    private char nom;
    private int occurence; 
 private boolean isJoker;
    DragSource ds;
      
    
    
    public Lettre(int valeur, char nom, int occurence){
    this.valeur=valeur;
    this.nom=nom;
    this.occurence=occurence;
      if(nom==' ')
       isJoker=true;
   else 
       isJoker=false;
  }
    
    public Lettre(Lettre l,Fenetre f)
    {
    this.valeur=l.getValeur();
    this.nom=l.getNom();
    this.occurence=l.getOccurence();
    if(nom==' ') this.setIcon(new ImageIcon("../joker.jpg"));
    else
    
    this.setIcon(new ImageIcon("../"+nom+".jpg"));
 if(l.isJoker())
     isJoker=true;
 else
     isJoker=false;
   
 
     ds=new DragSource();
     ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE,f);
             this.setSize(40,40);
    
    }
    
    public void setDragSource(boolean b)
    {
        ds.removeDragSourceListener(ds.getDragSourceListeners()[0]);
    }
    
    
    public void setOccurence(int occurence){
       if(occurence>=0) {
            this.occurence=occurence;
       
       
           
        }
    }

    public int getOccurence(){
    return occurence;
    }
    public int getValeur(){
    return valeur;
    }
    
    
    public char getNom() {
    return nom;}
      public void setNom(char nom) {
   this.nom=nom;}
        public boolean isJoker()
      {
          return isJoker;
      }
  
}
